﻿using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace WhySoSeries
{
    public abstract class WebsiteFactory
    {
        public string SiteUrl { get; private set; }
        protected List<Series> seriesList = null;

        protected WebsiteFactory(string websiteUrl)
        {
            this.SiteUrl = websiteUrl;
        }

        public List<Series> CreateSeriesList()
        {
            if (seriesList != null)
                return seriesList;

            List<string> links = this.CreateLinksProvider().GetSeriesLinksList();
            seriesList = new List<Series>();
            foreach (string link in links)
            {
                SeriesDataExtractor extractor = CreateDataExtractor(link);
                extractor.ExtractAllInfo();
                seriesList.Add(extractor.Series);
            }

            return seriesList;
        }

        public abstract SeriesDataExtractor CreateDataExtractor(Series series);
        protected abstract SeriesDataExtractor CreateDataExtractor(string link);
        protected abstract SeriesLinksProvider CreateLinksProvider();
    }
}
